package ru.scan2d.main.impl;

import java.awt.Component;

import javax.swing.JPanel;

import ru.scan2d.main.MainWindowPresenter;
import ru.scan2d.main.system.ClientFactory;
import ru.scan2d.main.system.ClientFactoryImpl;
import ru.scan2d.main.vizualizer.impl.VisualizerPresenterImpl;

public class MainWindowPresenterImpl implements MainWindowPresenter, MainWindowPresenter.Listener{

	private MainWindowImpl view;
	private VisualizerPresenterImpl visualizerPresenter;
	private ClientFactory clientFactory;
	
	public MainWindowPresenterImpl(){
		clientFactory = new ClientFactoryImpl();
		view = new MainWindowImpl(clientFactory.getMainMenuBar(this));
		view.setPresenter(this);
		view.setListener(this);
		visualizerPresenter = new VisualizerPresenterImpl(clientFactory, this);
		visualizerPresenter.go(null);
	}
	
	@Override
	public void needRepaint() {
		view.repaint();
		view.show();
	}

	@Override
	public void addCenterPanel(JPanel panel) {
		view.updateCenter(panel);
	}

	@Override
	public void onOpen() {
		visualizerPresenter.open();
	}

	@Override
	public void onSave() {
		visualizerPresenter.save();
	}

	@Override
	public void onClear() {
		visualizerPresenter.clear();
	}
}
